
package cn.org.seventh.tools.test.testcase;

import java.io.File;
import java.net.URL;

import junit.framework.TestCase;

import org.generama.FreeMarkerTemplateEngine;
import org.generama.MetadataProvider;
import org.generama.TemplateEngine;
import org.generama.WriterMapper;
import org.generama.defaults.FileWriterMapper;
import org.generama.tests.SinkWriterMapper;
import org.xdoclet.QDoxMetadataProvider;

import cn.org.seventh.tools.plugin.ServiceMethodImplementsPlugin;
import cn.org.seventh.tools.plugin.ServiceMethodInterfacePlugin;
import cn.org.seventh.tools.plugin.SpringManagePlugin;

/**
 * @author <a href="mailto:ji.li@symbio-group.com">Andy</a>
 * @since 2008-5-22 下午10:58:54
 */
public class RunPluginServiceMethod extends TestCase {
	private WriterMapper writerMapper;
	private MetadataProvider metadataProvider;
	private TemplateEngine templateEngine;
	@Override
	protected void setUp() throws Exception {
		// TODO Auto-generated method stub
		super.setUp();
		writerMapper = new SinkWriterMapper();
		URL reader = getClass().getResource("/");
		String path = reader.getPath() + "../../src/test/java/cn/org/seventh/tools/test/manage";
		metadataProvider = new QDoxMetadataProvider(new File(path));
		templateEngine = new FreeMarkerTemplateEngine();
	}
    public  void testGenerate() throws Exception {
       
        SpringManagePlugin plugin =
            new SpringManagePlugin(
    				(FreeMarkerTemplateEngine) templateEngine,
    				(QDoxMetadataProvider) metadataProvider, writerMapper);
        plugin.setMultioutput(false);
        plugin.start();
		System.out.println(((SinkWriterMapper) writerMapper).getContent());
        // ===============
        ServiceMethodInterfacePlugin plugin1 =
            new ServiceMethodInterfacePlugin(
    				(FreeMarkerTemplateEngine) templateEngine,
    				(QDoxMetadataProvider) metadataProvider, writerMapper);
        plugin1.start();
		System.out.println(((SinkWriterMapper) writerMapper).getContent());
        // ===============
        ServiceMethodImplementsPlugin plugin2 =
            new ServiceMethodImplementsPlugin(
    				(FreeMarkerTemplateEngine) templateEngine,
    				(QDoxMetadataProvider) metadataProvider, writerMapper);
        plugin2.start();
		System.out.println(((SinkWriterMapper) writerMapper).getContent());
        // System.out.println(writerMapper.getContent());
    }
}
